import React, { Fragment } from 'react'
import {
  View,
  ScrollView,

  Text
} from 'react-native'
import BasePage from 'src/pageP/base/base-page/index'
import CompanyTouchableOpacity from './components/CompanyTouchableOpacity'
import CustomButton from 'src/components/button/CustomButton'
import CustomModalAnimatable from '@/components/modal/CustomModalAnimatable'
import showPicker from 'src/utils/PickerUtil'
import Modal from './components/Modal'
import { CommonToast } from 'src/utils/ToastUtil'
import IMController from 'src/utils/IMController'
import moment from 'moment'
import styles from './css/index'
import CustomBoxShadow from 'src/components/boxshadow/CustomBoxShadow'
import { WXPay, IAPPay } from 'src/utils/PayUtil' // 支付
import { showModal } from 'src/utils/ModalUtil'
import GenerateModal from './components/generateModal'
/* redux */
import {
  getIndustryCategory,
  companyRightInfo, // 查询企业权益
  PublishPost, // 发布岗位
  getPostDetail, // 岗位详情
  submitPutawayApply, // 提交岗位申请 state 3 || 6 都上掉用这个接口
  updateState, // 上下架接口,
  deletePost, // 删除岗位
  memberPay, // 获取支付凭证
  updatePost, // 修改岗位信息
  postMessageStateRequest, // 查找发布消息的记录
  postMessageDeletedByPostIdRequest, // 消息删除成功，告知服务器
  postLookCompanyInfo
} from '@utils/RequestAPI'
import {
  education,
  postGetDegreeLevelByLabel,
  getPostEducation
  , settlementMethod as settlementMethodList
} from 'src/utils/ConfigUtil'
import { connect } from 'react-redux'
import { IS_IOS } from 'src/utils/ScreenUtil'
import { isString } from 'src/utils/JSTypeUtil'
import { keywordBlock } from 'src/utils/RegUtil'
import { AgreementJob, isEnv } from 'src/config/index'

const mapActiontoProps = dispatch => ({})

@connect(
  ({ userinfo, mineCompanyStore, BMineCenterStore }) => ({
    userinfo,
    ...mineCompanyStore,
    haveCompanyApply: BMineCenterStore.haveCompanyApply,
    userinfoB: userinfo.B
  }),
  mapActiontoProps
)
class PartTimeRelease extends BasePage {
  constructor(props) {
    super(props)
    this.state = {
      header: {
        // headerBg:'red'
      },
      visible: false, // 岗位类别 模态框
      showMask: false, // 薪资结算模态框
      updateStateModal: false, // 上架下架等提示模态框
      upgradeMemberModal: false, // 开通会员, 单次刷新等模态框
      isVip: false, // 是否是VIP
      updateState: 0, // 判断
      isOK: true, // 判断多次点击
      postId: undefined, // 单次发布时需要储存ID
      publishType: 0, // 开通会员, 单次刷新等模态框属于什么类型
      upgradeMemberModalTitle: '提示', // 开通会员, 单次刷新等模态框Title
      upgradeMemberModalText: '', // 开通会员, 单次刷新等模态框提示语
      typeList: ['兼职岗位', '全职岗位', '实习岗位'],
      dateList: ['小时', '天', '周', '月', '次'],
      stateType: ['招聘中', '已关闭', '', '平台下架', '永久下架', '上架待审核', '审核退回'],
      industryCategory: [], // 行也分类list
      type: 0,
      einmalText: '', // 开通会员, 单次刷新等模态框 取消按钮文案
      upgradeVipText: '', // 开通会员, 单次刷新等模态框确认按钮文案
      item: {
        isFast: 0, // 是否顶置 0 否 1 是
        state: undefined, // 0-已上架 1-未上架 2-未付款 3-平台下架 4-平台永久下架 5 上架待审核 6-上架申请拒绝） undefined为准备发布
        basicInfo: {
          anyWhere: 0,
          name: '',
          salary: '',
          category: '',
          workContent: '',
          unit: '',
          type: 0,
          welfare: [],
          companyId: null,
          settlementMethod: '',
          education: '',
          practiceLabel: 0
        },
        postWorkLocations: []
      }
    }
  }

  static jobInfoCompleted = (item, tip = false) => {
    const { basicInfo: { name, category, education, salary, unit, settlementMethod, workContent }, postWorkLocations } = item
    const enable = [
      {
        key: name,
        value: '岗位名称'
      },
      {
        key: category,
        value: '岗位类别'
      },
      {
        key: education,
        value: '学历要求'
      },
      {
        key: salary !== '' && unit !== '' && settlementMethod !== '',
        value: '薪资结算'
      },
      {
        key: workContent,
        value: '工作内容'
      },
      {
        key: postWorkLocations && postWorkLocations.length,
        value: '工作地点'
      }
    ].every(e => {
      if (tip && !e.key) {
        CommonToast(`请完善${e.value}信息`)
      }
      return e.key
    })
    return enable
  }

  /* 学历要求 */
  onClick = () => {
    const pickerData = education.map((item) => { return item.key })
    const selectedValue = []
    const pickerTitleText = '最低学历'
    if (this.state.item.state !== 5) {
      showPicker({
        pickerData,
        selectedValue,
        pickerTitleText,
        onConfirm: ([gmtBorth]) => {
          const item = this.state.item
          item.basicInfo.education = postGetDegreeLevelByLabel(gmtBorth)
          this.setState({
            item: item
          })
        }
      })
    }
  }

  /* 薪资结算 */
  generateModal = () => {
    const { type } = this.props.navigation.state.params
    this.salleryModal = showModal(<GenerateModal type={type} item={this.state.item} commonFix={this.commonFix} onOK={this.onOK} />)
  }

  /* 全职/实习薪资修复 */
  commonFix = (salary, unit, settlementMethod) => {
    // 全职 实习 时  修正错误数据 ，正确的位月结/按月
    let { item } = this.state
    if (salary !== '' && unit !== '' && settlementMethod >= 0) {
      item = {
        ...item,
        basicInfo: {
          ...item.basicInfo,
          salary,
          unit,
          settlementMethod
        }
      }
      this.setState({
        item
      })
    }
  }

  /* 薪资结算确定 */
  onOK = (salary, unit, settlementMethod) => {
    let { item } = this.state
    if (salary !== '' && unit !== '' && settlementMethod >= 0) {
      item = {
        ...item,
        basicInfo: {
          ...item.basicInfo,
          salary,
          unit,
          settlementMethod
        }
      }
      console.log(item, 'item')
      this.closeSalleryModal()
      this.setState({
        item,
        showMask: false
      })
    }
  }

  /* 关闭薪资结算窗口 */
  closeSalleryModal = (callBack) => {
    this.salleryModal.close(callBack)
  }

  /* 岗位置顶 */
  isFastFn = () => {
    const item = this.state.item
    if (!(item.state === 5 || item.state === 0)) {
      item.isFast = item.isFast === 1 ? 0 : 1
      this.setState({
        item
      })
    }
  }

  /* 岗位类别 */
  toggleMask = showMask => {
    if (this.state.item.state !== 5) {
      if (!showMask.visible && this.state.item.state >= 0) {
        this.setState({
          ...showMask
        })
      } else {
        this.setState({
          ...showMask
        })
      }
    }
  }

  /* 岗位类别 确定 */
  modalOnOk = (text) => {
    const item = this.state.item
    item.basicInfo.category = text
    this.setState({
      item,
      visible: false
    })
  }

  /* 已发布岗位导航栏状态 */
  stateText = (state) => {
    // （0-已上架 1-未上架 2-未付款 3-平台下架 4-平台永久下架 5 上架待审核 6-上架申请拒绝）
    let text = ''
    switch (state) {
      case 0:
        text = '下架'
        break
      case 3:
        text = '请求上架'
        break
      case 5:
        text = '审核中'
        break
      case 6:
        text = '重新申请'
        break
      case 4:
        text = '联系客服'
        break
      default:
        text = '上架'
        break
    }
    return text
  }

  updateStateModalFn = () => {
    const { item, updateState } = this.state
    if (updateState === 2) {
      deletePost({ params: { id: item.id } }).then((data) => {
        if (data.code === 200) {
          const { getMyPostList, type } = this.props.navigation.state.params
          this.setState({
            updateStateModal: false
          })
          CommonToast('删除成功')
          this.jumpFn()
          getMyPostList(type)
        }
      })
    } else {
      this.updateState(item, updateState)
    }
  }

  /* 发布/保存岗位 */
  toastModla = () => {
    if (this.state.isVip) {
      this.publish()
    } else {
      const { item, vipEquity } = this.state
      if (PartTimeRelease.jobInfoCompleted(item, true)) {
        this.setState({
          upgradeMemberModal: true,
          upgradeVipText: '发布',
          upgradeMemberModalText: `非会员拥有2次免费发布机会, 你已经发布${2 - vipEquity.postPublish}次` + (vipEquity.postPublish > 0 ? `, 还有${vipEquity.postPublish}次免费机会` : ''),
          einmalText: '取消',
          publishType: 4
        })
      }
    }
  }

  publish = () => {
    const { item, isOK } = this.state
    const { getMyPostList, type } = this.props.navigation.state.params
    const { haveCompanyApply } = this.props
    if (item.state !== 5) {
      if (item.state !== undefined) {
        // 岗位修改
        updatePost({
          params: {
            ...item.basicInfo,
            postId: item.id
          }
        }).then((data) => {
          if (data.code === 200) {
            CommonToast('编辑成功')
            getMyPostList(type)
          }
        })
      } else {
        const { item } = this.state
        if (PartTimeRelease.jobInfoCompleted(item, true)) {
          if (isOK) {
            this.setState({
              isOK: false
            })
            // 发布岗位
            PublishPost({
              params: {
                isFast: item.isFast,
                basicInfoModel: {
                  ...item.basicInfo,
                  type: type !== 2 ? type : 1,
                  practiceLabel: type !== 2 ? 0 : 1
                },
                postWorkLocations: item.postWorkLocations,
                companyId: haveCompanyApply.companyId,
                userId: this.props.userinfo.userId
              },
              headers: {
                companyId: haveCompanyApply.companyId
              }
            }).then((data) => {
              if (data.code === 200) {
                const { getMyPostList, type } = this.props.navigation.state.params
                CommonToast('发布成功')
                this.jumpFn()
                getMyPostList(type)
                // 删除主动发送的消息
                this.dealImMessage({ postId: data.data })
              } else if (data.code == 101 || data.code == 102 || data.code == 100) {
                if (data.message == 1) {
                  this.isFastPay()
                } else if (data.message == 0) {
                  this.setState({
                    postId: data.data
                  })
                  this.publishPay()
                }
              }
              this.setState({
                isOK: true
              })
            }).catch(() => {
              this.setState({
                isOK: true
              })
            })
          }
        }
      }
    }
  }

  // 发布岗位单次支付
  publishPay = () => {
    let upgradeMemberModalText = ''
    let upgradeVipText = ''
    let einmalText = ''
    let publishType = 0
    const { vipEquity } = this.state
    if (this.state.isVip) {
      upgradeVipText = '单次发布'
      upgradeMemberModalText = `当前您为${vipEquity.memberLevel},本月免费发布岗位岗位已用完`
      einmalText = '取消发布'
      publishType = 2
    } else {
      upgradeVipText = '升级会员'
      upgradeMemberModalText = `非会员拥有2次免费发布机会, 你已经发布${2 - vipEquity.postPublish}次` + (vipEquity.postPublish > 0 ? `, 还有${vipEquity.postPublish}次免费机会` : '')
      einmalText = '单次发布'
      publishType = 3
    }
    this.setState({
      upgradeMemberModal: true,
      einmalText,
      upgradeVipText,
      publishType,
      upgradeMemberModalText
    })
  }

  // 未开通会员顶置模态框弹出
  isFastPay = () => {
    this.setState({
      upgradeMemberModal: true,
      einmalText: '返回修改',
      upgradeVipText: '升级会员',
      publishType: 1,
      upgradeMemberModalText: '当前您不是会员无法顶置,会员可以顶置哦'
    })
  }

  // 当岗位状态 为0|| 1 的时候点击保存调用
  updateState = (item, state) => {
    updateState({ params: { postId: item.id, state } }).then((data) => {
      if (data.code === 200) {
        const { getMyPostList, type } = this.props.navigation.state.params
        CommonToast(state === 0 ? '上架成功' : '下架成功')
        this.setState({
          updateStateModal: false
        })
        this.jumpFn()
        getMyPostList(type)
      }
    })
  }

  deletePostFn = () => {
    this.setState({
      updateStateModal: true,
      updateState: 2
    })
  }

  //  岗位状态为3 || 6调用
  submitPutawayApplyFn = (item) => {
    const { getMyPostList, type } = this.props.navigation.state.params
    submitPutawayApply({ params: { postId: item.id } }).then((data) => {
      if (data.code === 200) {
        CommonToast('提交申请成功')
        getMyPostList(type)
      }
    })
  }

  // 保存按钮  并判断是什么状态的数据而进行一系列的操作
  prewClick = () => {
    const { item } = this.state
    switch (item.state) {
      case 0:
        this.toggleMask({ updateStateModal: true, updateState: 1 })
        break
      case 1:
        this.toggleMask({ updateStateModal: true, updateState: 0 })
        break
      case 3:
        this.submitPutawayApplyFn(item)
        break
      case 6:
        this.submitPutawayApplyFn(item)
        break
    }
  }

  // 回调
  getData = (postWorkLocations, WorkLocations) => {
    const { item } = this.state
    this.setState({
      item: {
        ...item,
        postWorkLocations,
        WorkLocations
      }
    })
    this.props.navigation.navigate('PartTimeRelease')
  }

  // 跳转到岗位地址添加页面
  jumpMapView = ({ isPitchOnList }) => {
    if (this.state.item.state == undefined) {
      const { haveCompanyApply, userinfoB } = this.props
      this.props.navigation.navigate('AddSite', {
        getData: this.getData,
        companyId: haveCompanyApply.companyId,
        userId: userinfoB.userId,
        isPitchOnList: isPitchOnList || []
      })
    } else {
      CommonToast('该字段无法编辑')
    }
  }

  // 跳转到岗位列表
  jumpFn = () => {
    this.props.navigation.navigate('JobPartTime')
  }

  // 跳转岗位名称,工作内容输入页面
  jumpBusinessAddress = ({ type, item }) => {
    const saveCallback = postion => {
      const { item } = this.state
      if (type === 1) {
        item.basicInfo.name = postion
      } else {
        item.basicInfo.workContent = postion
      }
      this.setState({
        item
      })
    }
    this.props.navigation.navigate('CommonInputPage', { ...item, saveCallback })
  }

  // 查询当前企业权限
  searchVipEquity = () => {
    const { haveCompanyApply } = this.props
    companyRightInfo({ headers: { companyId: haveCompanyApply.companyId } }).then((data) => {
      this.setState({
        vipEquity: data.data,
        isVip: data.data.member
      })
    })
  }

  componentWillFocus() {
    this.searchVipEquity()
  }

  componentDidMount() {
    const { haveCompanyApply } = this.props
    const { navigation: { state: { params: { item } } } } = this.props
    companyRightInfo({ headers: { companyId: haveCompanyApply.companyId } }).then((data) => {
      if (data.data.member && data.data.postPublish === 0 && !item) {
        this.setState({
          upgradeMemberModal: true,
          upgradeVipText: '确定',
          upgradeMemberModalText: '贵公司发布岗位次数已达上限',
          einmalText: '取消',
          publishType: 5
        })
      }
      this.setState({
        vipEquity: data.data,
        isVip: data.data.member
      })
    })
    // type 代表是兼职-0, 全职-1, 实习-2
    this.setState({
      type: this.props.navigation.state.params.type
    })
    // 获取行业分类
    getIndustryCategory({ params: { type: this.props.navigation.state.params.type } }).then(({ data: industryCategory }) => {
      this.setState({
        industryCategory
      })
    })
    if (item && item.id) {
      // 点击岗位列表的某一条数据跳转进来 调用岗位详情接口
      getPostDetail({ params: { postId: item.id } }).then((data) => {
        const WorkLocations = []
        data.data.postWorkLocations.map((item) => {
          WorkLocations.push(item.addressSimple || item.address)
        })
        data.data.WorkLocations = WorkLocations
        this.setState({
          item: data.data,
          salary: data.data.basicInfo.salary + '',
          settlementMethod: data.data.basicInfo.settlementMethod,
          unit: data.data.basicInfo.unit || data.data.basicInfo.settlementMethod + 1
        })
      })
    }
  }

  // 当state > 0 时这个函数代替跳转函数 以减少控制太报红
  empty = () => {
    CommonToast('该字段无法编辑')
  }

  // 点击预览时判断信息有没有填写完整
  jumpCJobdetail = ({ jump, items }) => {
    const { item } = this.state
    if (PartTimeRelease.jobInfoCompleted(item, true)) {
      if (item.state !== undefined) {
        item.bossInfo = { ...this.props.userinfoB, avator: this.props.userinfoB.userAvator }
        this.props.navigation.navigate(jump, { id: null, item: items })
      } else {
        postLookCompanyInfo({ params: { companyId: this.props.haveCompanyApply.companyId } }).then((data) => {
          item.bossInfo = { ...this.props.userinfoB, avator: this.props.userinfoB.userAvator }
          item.workMates = data.data.workMates
          item.companyInfo = data.data.companyInfo
          item.companyBaseInfo = data.data.companyBaseInfo
          item.bossInfo.collectionArchiveCount = data.data.bossInfo.collectionArchiveCount
          console.log(item, data)
          this.props.navigation.navigate(jump, { id: null, item: items })
        })
      }
    }
  }

  // 当已开通会员并且发布岗位次数为零 单次刷新 与关闭模态框
  upgradeMember = () => {
    const { publishType, postId } = this.state
    const { userinfoB, haveCompanyApply } = this.props

    if (publishType === 1 || publishType === 3) {
      // 关闭模态框
      this.toggleMask({ upgradeMemberModal: false })
      this.props.navigation.navigate('BMemberOpen')
    } else if (publishType === 2) {
      const params = {
        businessType: 'publishPost',
        postId,
        userId: userinfoB.userId,
        companyId: haveCompanyApply.companyId,
        orderName: '岗位单次发布'
      }
      this.publicPay(params)
    } else if (publishType === 4) {
      this.publish()
    } else if (publishType === 5) {
      this.shutModal()
    }
  }

  // 关闭所有模态框
  shutModal = () => {
    this.setState({
      showMask: false,
      updateStateModal: false,
      upgradeMemberModal: false
    })
  }

  // 单次岗位发布 与关闭模态框
  einmal = () => {
    const { publishType, postId } = this.state
    if (publishType === 1 || publishType === 2) {
      this.shutModal() // 关闭模态框
    } else if (publishType === 3) {
      // 调微信支付
      const { userinfoB, haveCompanyApply } = this.props
      const params = {
        businessType: 'publishPost',
        postId,
        userId: userinfoB.userId,
        companyId: haveCompanyApply.companyId,
        orderName: '岗位单次发布'
      }
      this.publicPay(params)
    } else if (publishType === 4) {
      this.setState({
        upgradeMemberModal: false,
        publishType: 0
      })
    } else if (publishType === 5) {
      this.shutModal()
    }
  }

  publicPay = (params) => {
    // debugger
    if (IS_IOS) {
      params['payWay'] = 'iosApp'
      memberPay({ params })
        .then(res => {
          const { iapId, recordId } = res.data
          const { companyId, userId, postId } = params
          return IAPPay({ iapId, recordId, postId, companyId, userId, businessType: 'PUBLISH_POST' })
        }).then((res) => {
          this.shutModal(false)
          const { getMyPostList, type } = this.props.navigation.state.params
          CommonToast('发布成功')
          getMyPostList(type)
          this.jumpFn()
          // 删除主动发送的消息
          this.dealImMessage({ postId: res })
        }).catch(error => {
          isString(error) && CommonToast(error)
        })
    } else {
      params['payWay'] = 'wxApp'
      memberPay({ params }).then((res) => {
        return WXPay(res.data)
      }).then((res) => {
        this.shutModal(false)
        const { getMyPostList, type } = this.props.navigation.state.params
        getMyPostList(type)
        CommonToast('发布成功')
        this.jumpFn()
        // 删除主动发送的消息
        this.dealImMessage({ postId: res })
      }).catch(error => {
        isString(error) && CommonToast(error)
      })
    }
  }

  jump = () => {
    this.props.navigation.navigate('CommonWebView', {
      source: { uri: AgreementJob }
    })
  }

  dealImMessage = ({ postId }) => {
    // 删除主动发送的im消息
    this.messageTimes++
    if (this.messageTimes > 50) {
      return false
    }
    setTimeout(() => {
      // 轮询接口 判断消息是否发送成功
      postMessageStateRequest({ postId }).then((data) => {
        const { data: entry } = data
        const { ids, state } = entry
        if (state === 1) {
          // 发送消息成功
          // 格式： [{ scene: 'p2p', to: 'account' }, { scene: 'p2p', to: 'account1' }]
          const sessions = []
          const userIdArr = ids.split(',')
          userIdArr.map(item => {
            sessions.push({
              scene: 'p2p',
              to: `${item}c${isEnv}`
            })
            return item
          })
          IMController.deleteSessions({ sessions }).then(status => {
            if (status) {
              IMController.initNIMb()
              // 删除消息成功 通知后端
              postMessageDeletedByPostIdRequest({ postId })
              return ''
            } else {
              CommonToast('消息失败~')
              return this.dealImMessage({ postId })
            }
          })
        } else if (state === -1) {
          // 不存在
          return this.dealImMessage({ postId })
        } else if (state === 0) {
          // 无消息
          return ''
        }
      })
    }, 200)
  }

  childRender() {
    const {
      upgradeMemberModalTitle, upgradeMemberModalText, dateList, updateState, updateStateModal,
      einmalText, upgradeVipText, upgradeMemberModal,
      visible, industryCategory, item, stateType, typeList, type
    } = this.state
    const { basicInfo } = item
    return (
      <ScrollView showsVerticalScrollIndicator={false} style={styles.container}>
        <View style={styles.title}>
          <Text style={styles.titleName}>{typeList[type]}</Text>
          <View style={styles.titleView}>
            <Text style={styles.titleText}>岗位名称、类型发布之后不可修改</Text>
            <Text style={styles.titleState}>{stateType[item.state]}</Text>
          </View>
        </View>
        <CompanyTouchableOpacity
          title='岗位名称'
          onPress={item.state === undefined ? this.jumpBusinessAddress : this.empty}
          params={{
            type: 1,
            item: {
              title: '岗位名称',
              blockReg: keywordBlock,
              desc: '*不能填联系方式以及特殊符号',
              placeholder: '请输入岗位名称',
              maxLength: 12,
              value: (basicInfo || {}).name || ''
            }
          }}
          url={require('@/imgC/part/part_right.png')}
          valueList={(basicInfo || {}).name ? [basicInfo.name] : []}
        />
        <View style={styles.jobInformationList}>
          <CustomBoxShadow style={styles.jobInformationListItemShadow}>
            <CustomButton
              onPress={item.state === undefined ? this.toggleMask : this.empty}
              params={{ visible: true }}
              style={styles.jobInformationListItem}>
              <Text style={styles.jobInformationItemtitle}>岗位类别</Text>
              <Text style={styles.jobInformationText}>{(basicInfo || {}).category || '请选择'}</Text>
            </CustomButton>
          </CustomBoxShadow>
          <CustomBoxShadow style={styles.jobInformationListItemShadow}>
            <CustomButton onPress={this.onClick} style={styles.jobInformationListItem}>
              <Text style={styles.jobInformationItemtitle}>学历要求</Text>
              <Text style={styles.jobInformationText}>{getPostEducation((basicInfo || {}).education > 9 ? Math.floor((basicInfo || {}).education / 10) : (basicInfo || {}).education) || '请选择'}</Text>
            </CustomButton>
          </CustomBoxShadow>
          <CustomBoxShadow style={styles.jobInformationListItemShadow}>
            <CustomButton
              onPress={this.generateModal}
              params={{ showMask: true }}
              style={styles.jobInformationListItem}>
              <Text style={styles.jobInformationItemtitle}>{(basicInfo || {}).settlementMethod !== '' ? settlementMethodList[(basicInfo || {}).settlementMethod || 0].name : '薪资结算'}</Text>
              <Text style={styles.jobInformationText}>{(((basicInfo || {}).salary !== '' && (basicInfo || {}).settlementMethod !== '') && (basicInfo || {}).salary + '元/' + dateList[(basicInfo || {}).unit !== '' ? (basicInfo || {}).unit : (basicInfo || {}).settlementMethod]) || '请选择'}</Text>
            </CustomButton>
          </CustomBoxShadow>
        </View>
        <CompanyTouchableOpacity
          title='工作内容'
          onPress={item.state === 5 ? this.empty : this.jumpBusinessAddress}
          params={{
            type: 2,
            item: {
              title: '工作内容',
              blockReg: keywordBlock,
              desc: '*不能填联系方式以及特殊符号',
              placeholder: '请输入工作内容',
              maxLength: 2000,
              multiline: true,
              value: (basicInfo || {}).workContent || `【工作内容】\n  \n  \n【工作要求】\n  \n  \n【人员要求】 \n  \n  \n  `
            }
          }}
          url={require('@/imgC/part/part_right.png')}
          valueList={(basicInfo || {}).workContent ? [basicInfo.workContent] : []}
        />
        <CompanyTouchableOpacity
          title='工作地点'
          onPress={this.jumpMapView}
          params={{ isPitchOnList: item.postWorkLocations }}
          valueIcon={require('@/imgC/company/vip_icon.png')}
          value='VIP可添加多个地点'
          valueStyle={styles.valueStyle}
          url={require('@/imgC/part/part_right.png')}
          valueList={item.WorkLocations} />
        <CompanyTouchableOpacity
          isFastFn={this.isFastFn}
          type={true}
          isFast={!!item.isFast}
          title='岗位置顶'
          disabled={moment() - moment(item.gmtCreate) > 259200000 || item.state === 5 || item.state === 0}
          icon={require('@/imgC/member/vip_icon.png')}
          url={require('@/imgC/part/part_right.png')}
        />
        {/* <CompanyTouchableOpacity type={true} title='自动刷新' icon={require('@/imgC/member/vip_icon.png')} url={require('@/imgC/company/icon_right.png')} /> */}
        <Text style={styles.Bottom}>*发布职位即表示遵守 <Text onPress={this.jump} style={styles.bottomText}>《人职初信息发布规则》</Text>，如违反会导致岗位 被退回以及账号被锁定</Text>
        <View style={styles.buttonData}>
          <CustomButton onPress={this.jumpCJobdetail} params={{ jump: 'CJobdetail', items: item }}
            style={styles.buttonOne}>
            <Text style={styles.buttonOneText}>预览</Text>
          </CustomButton>
          <CustomButton onPress={item.state === undefined ? this.toastModla : this.publish}
            style={[styles.buttonTow, (item.state === 5) && { backgroundColor: '#ccc' }]}>
            <Text
              style={[styles.buttonTowText, (item.state === 5) && { color: '#444' }]}>{item.state !== undefined ? '保存' : '发布'}</Text>
          </CustomButton>
        </View>
        {/* 薪资结算模态框 */}

        {/* 上架下架等提示模态框 */}
        <CustomModalAnimatable onCancel={this.shutModal} visible={updateStateModal}>
          <View style={styles.updateStateModalView}>
            <Text style={styles.updateStateModalTitle}>提醒</Text>
            <Text
              style={styles.updateStateModalText}>{updateState === 1 ? '确定要下架该职位吗？' : updateState === 0 ? '确定要上架该职位吗？' : updateState === 2 ? '确定要删除该岗位吗?' : ''}</Text>
            <CustomButton onPress={this.toggleMask} params={{ updateStateModal: false, updateState: 0 }}
              style={styles.updateStateModalNoBtn}><Text style={styles.updateStateModalNoBtnText}>取消</Text></CustomButton>
            <CustomButton onPress={this.updateStateModalFn} style={styles.updateStateModalYesBtn}><Text
              style={styles.updateStateModalYesBtnText}>确定</Text></CustomButton>
          </View>
        </CustomModalAnimatable>
        {/* 开通会员, 单次刷新等模态框 */}
        <CustomModalAnimatable onCancel={this.shutModal} visible={upgradeMemberModal}>
          <View style={styles.updateStateModalView}>
            <Text style={styles.updateStateModalTitle}>{upgradeMemberModalTitle}</Text>
            <Text style={styles.updateStateModalText}>{upgradeMemberModalText}</Text>
            <CustomButton onPress={this.einmal} style={styles.updateStateModalNoBtn}><Text
              style={styles.updateStateModalNoBtnText}>{einmalText}</Text></CustomButton>
            <CustomButton onPress={this.upgradeMember} style={styles.updateStateModalYesBtn}><Text
              style={styles.updateStateModalYesBtnText}>{upgradeVipText}</Text></CustomButton>
          </View>
        </CustomModalAnimatable>
        {/* 岗位类别 */}
        <Modal
          category={(item.basicInfo || {}).category || ''}
          toggleMask={this.toggleMask}
          visible={visible}
          modalOnOk={this.modalOnOk}
          industryCategory={industryCategory}
        />
      </ScrollView>
    )
  }

  renderNavigationBarChild = () => {
    const { item } = this.state
    return (
      <View style={styles.headerView}>
        {!!item.id && <CustomButton style={[styles.naviBtnBG]} onPress={this.prewClick}>
          <Text>{this.stateText(item.state)}</Text>
        </CustomButton>}
        {
          item.state === 1 && <CustomButton style={[styles.naviBtnBG]} onPress={this.deletePostFn}>
            <Text>删除</Text>
          </CustomButton>
        }
      </View>
    )
  }
}

export default PartTimeRelease
